<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <!--<div class="form-group">-->
    <!--<label for="c-userId" class="control-label col-xs-12 col-sm-2">{:__('brandId')}:</label>-->
    <!--<div class="col-xs-12 col-sm-8">-->
    <!--<input id="c-userId" class="form-control selectpage" data-db-table="user" data-field="name"-->
    <!--data-primary-key="userId" data-params='{"row[company]":"1"}' name="row[userId]" type="text" value="" data-rule="required">-->
    <!--</div>-->
    <!--</div>-->

    <div class="form-group">
        <label for="c-userId" class="control-label col-xs-12 col-sm-2">{:__('userId')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-userId" class="form-control selectpage" data-db-table="user" data-field="name"
                   data-primary-key="userId" data-params='{"custom[company]":"1"}' name="row[userId]" type="text" value="{$row['userId']}" data-rule="required">
        </div>
    </div>

    <!--<div class="form-group">-->
    <!--<label for="c-userId" class="control-label col-xs-12 col-sm-2">{:__('UserId')}:</label>-->
    <!--<div class="col-xs-12 col-sm-8">-->
    <!--<input id="c-userId" data-rule="required" class="form-control" name="row[userId]" type="number" value="0">-->
    <!--</div>-->
    <!--</div>-->




    <div class="form-group">
        <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[type]', $typeList,$row['type'])}
        </div>
    </div>
    <div class="form-group">
        <label for="c-pledge" class="control-label col-xs-12 col-sm-2">{:__('Pledge')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[pledge]',$pledge, $row['pledge'])}
        </div>
    </div>

    <div class="form-group">
        <label for="c-pledge" class="control-label col-xs-12 col-sm-2">{:__('Acttype')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[actType]', $actType,$row['actType'])}
        </div>
    </div>





    <div class="form-group">
        <label for="c-isDay" class="control-label col-xs-12 col-sm-2">{:__('IsDay')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-isDay" name="row[isDay]" class="form-control" onchange="chooserepay()" >
                <option value="1" {if condition="$row['isDay'] == 1"}selected{/if} >天标</option>
                <option value="0" {if condition="$row['isDay'] == 0"}selected{/if} >月标</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="c-time" class="control-label col-xs-12 col-sm-2">{:__('Time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-time" data-rule="required" class="form-control "  data-use-current="true" name="row[time]" value="{$row['time']}" type="text" style="width: 80%;" >
            <span id="days">{if condition="$row['isDay'] == 1"}天{else}月{/if}</span>
        </div>
    </div>

    <div class="form-group"  id="repaystyle"  {if condition="$row['isDay'] == 0"} style="display:none;" {/if}   >
        <label for="c-repayType" class="control-label col-xs-12 col-sm-2">{:__('RepayType')}:</label>
        <div class="col-xs-12 col-sm-8">
            <!--<input id="c-repayType" data-rule="required" class="form-control" name="row[repayType]" type="number" value="0">-->
            到期一次还本付息
        </div>
    </div>


    <div class="form-group"  id="repaystyle1" {if condition="$row['isDay'] == 1"} style="display:none;" {/if}>
        <label for="c-repayType" class="control-label col-xs-12 col-sm-2">{:__('RepayType')}:</label>
        <div class="col-xs-12 col-sm-8">
            <!--<input id="c-repayType" data-rule="required" class="form-control" name="row[repayType]" type="number" value="0">-->
            <select id="c-repayType" name="row[repayType]" class="form-control"  >
                <option value="2"   {if condition="$row['repayType'] == 2"}selected{/if}>按月还本息</option>
                <option value="3"   {if condition="$row['repayType'] == 3"}selected{/if}>按月还息，到期还本</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="c-useCards" class="control-label col-xs-12 col-sm-2">{:__('UseCards')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-useCards" name="row[useCards]" class="form-control"  >
                <option value="1"  {if condition="$row['useCards'] == 1"}selected{/if} >可用卡券</option>
                <option value="0"  {if condition="$row['useCards'] == 0"}selected{/if} >不可用卡券</option>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label for="c-account" class="control-label col-xs-12 col-sm-2">专属活动:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-activityId" class="form-control" name="row[activityId]">
                <option value="0">无</option>
                {foreach name="activitylist" id='vv'}
                <option value="{$vv['id']}"  {if($vv['id']==$row['activityId'])}selected{/if}>{$vv['title']}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label for="c-account" class="control-label col-xs-12 col-sm-2">{:__('Account')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-account" data-rule="required" class="form-control"  name="row[account]" type="text" value="{$row['account']}">
        </div>
    </div>

    <div class="form-group">
        <label for="c-aprBase" class="control-label col-xs-12 col-sm-2">{:__('AprBase')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-aprBase" data-rule="" class="form-control"  name="row[aprBase]" type="text" value="{$row['aprBase']}">%
        </div>
    </div>
    <div class="form-group">
        <label for="c-aprAdd" class="control-label col-xs-12 col-sm-2">{:__('AprAdd')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-aprAdd" data-rule="required" class="form-control"  name="row[aprAdd]" type="text" value="{$row['aprAdd']}">%
        </div>
    </div>

    <div class="form-group">
        <label for="c-limitMoney" class="control-label col-xs-12 col-sm-2">{:__('LimitMoney')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-limitMoney" data-rule="required" class="form-control"  name="row[limitMoney]">
                <option  value="100"  >100元</option>
                <option  value="1000" {if($row['limitMoney']==1000)} selected{/if} >1000元</option>
                <option  value="10000" {if($row['limitMoney']==1000)} selected{/if} >10000元</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="c-validDay" class="control-label col-xs-12 col-sm-2">{:__('ValidDay')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-validDay" data-rule="required" class="form-control" name="row[validDay]" type="number" value="{$row['validDay']}">
        </div>
    </div>


    <div class="form-group">
        <label for="c-borrowerInfo" class="control-label col-xs-12 col-sm-2">{:__('Projectuse')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-projectUse" data-rule="required" class="form-control" rows="3" name="detail[projectUse]" cols="60">{$row['detail']['projectUse']}</textarea>
            <span>(借款用途必填，为空时 审核无法通过)</span>
        </div>
    </div>


    <div class="form-group">
        <label for="c-validDay" class="control-label col-xs-12 col-sm-2">{:__('BorrowTemp')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="borrowtemp" onchange="choosetemp()" class="form-control">
                <option value=""  >请选择</option>
                {foreach name="borrowTemp" id='vv'}
                <option value="{$vv.id}"  >{$vv.tempname}</option>
                {/foreach}
            </select>
        </div>
    </div>


    <div class="form-group">
        <label for="c-name" class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row['name']}">
        </div>
    </div>


    <div class="form-group">
        <label for="c-itemInfo" class="control-label col-xs-12 col-sm-2">{:__('ItemInfo')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-itemInfo" data-rule="" class="form-control summernote" rows="5" name="detail[itemInfo]" cols="50">{$row['detail']['itemInfo']}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label for="c-itemImages" class="control-label col-xs-12 col-sm-2">{:__('ItemImgs')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="form-inline">
                <input id="c-itemImages" data-rule="" class="form-control" size="50" name="detail[itemImgs]" type="text" value="{$row['detail']['itemImgs']}">
                <span><button type="button" id="plupload-itemImages" class="btn btn-danger plupload" data-input-id="c-itemImages" data-url="{:url('ajax/upload',array('from'=>'borrow'))}" data-mimetype="image/*" data-multiple="true" data-preview-id="p-itemImages"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                <span><button type="button" id="fachoose-itemImages" class="btn btn-primary fachoose" data-input-id="c-itemImages" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                <ul class="row list-inline plupload-preview" id="p-itemImages"></ul>
            </div>
        </div>
    </div>



    <div class="form-group">
        <label for="c-borrowerInfo" class="control-label col-xs-12 col-sm-2">{:__('BorrowerInfo')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-borrowerInfo" data-rule="" class="form-control summernote" rows="5" name="detail[borrowerInfo]" cols="50">{$row['detail']['borrowerInfo']}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label for="c-borrowerImages" class="control-label col-xs-12 col-sm-2">{:__('BorrowerImgs')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="form-inline">
                <input id="c-borrowerImages" data-rule="" class="form-control" size="50" name="detail[borrowerImgs]" type="text" value="{$row['detail']['borrowerImgs']}">
                <span><button type="button" id="plupload-borrowerImages" class="btn btn-danger plupload" data-input-id="c-borrowerImages" data-url="{:url('ajax/upload',array('from'=>'borrow'))}" data-mimetype="image/*" data-multiple="true" data-preview-id="p-borrowerImages"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                <span><button type="button" id="fachoose-borrowerImages" class="btn btn-primary fachoose" data-input-id="c-borrowerImages" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                <ul class="row list-inline plupload-preview" id="p-borrowerImages"></ul>
            </div>
        </div>
    </div>




    <div class="form-group">
        <label for="c-repaymentInfo" class="control-label col-xs-12 col-sm-2">{:__('RepaymentInfo')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-repaymentInfo" data-rule="" class="form-control summernote" rows="5" name="detail[repaymentInfo]" cols="50">{$row['detail']['repaymentInfo']}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label for="c-repaymentImages" class="control-label col-xs-12 col-sm-2">{:__('RepaymentImgs')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="form-inline">
                <input id="c-repaymentImages" data-rule="" class="form-control" size="50" name="detail[repaymentImgs]" type="text" value="{$row['detail']['repaymentImgs']}">
                <span><button type="button" id="plupload-repaymentImages" class="btn btn-danger plupload" data-input-id="c-repaymentImages" data-url="{:url('ajax/upload',array('from'=>'borrow'))}" data-mimetype="image/*" data-multiple="true" data-preview-id="p-repaymentImages"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                <span><button type="button" id="fachoose-repaymentImages" class="btn btn-primary fachoose" data-input-id="c-repaymentImages" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                <ul class="row list-inline plupload-preview" id="p-repaymentImages"></ul>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label for="c-riskInfo" class="control-label col-xs-12 col-sm-2">{:__('RiskInfo')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-riskInfo" data-rule="" class="form-control summernote" rows="5" name="detail[riskInfo]" cols="50">{$row['detail']['riskInfo']}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label for="c-riskImages" class="control-label col-xs-12 col-sm-2">{:__('RiskImgs')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="form-inline">
                <input id="c-riskImages" data-rule="" class="form-control" size="50" name="detail[riskImgs]" type="text" value="{$row['detail']['riskImgs']}">
                <span><button type="button" id="plupload-riskImages" class="btn btn-danger plupload" data-input-id="c-riskImages" data-url="{:url('ajax/upload',array('from'=>'borrow'))}" data-mimetype="image/*" data-multiple="true" data-preview-id="p-riskImages"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                <span><button type="button" id="fachoose-riskImages" class="btn btn-primary fachoose" data-input-id="c-riskImages" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                <ul class="row list-inline plupload-preview" id="p-riskImages"></ul>
            </div>
        </div>
    </div>


    <div class="form-group">
        <label for="c-projectInfo" class="control-label col-xs-12 col-sm-2">{:__('ProjectInfo')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-projectInfo" data-rule="" class="form-control summernote" rows="5" name="detail[projectInfo]" cols="50">{$row['detail']['projectInfo']}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label for="c-projectImages" class="control-label col-xs-12 col-sm-2">{:__('ProjectImgs')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="form-inline">
                <input id="c-projectImages" data-rule="" class="form-control" size="50" name="detail[projectImgs]" type="text" value="{$row['detail']['projectImgs']}">
                <span><button type="button" id="plupload-projectImages" class="btn btn-danger plupload" data-input-id="c-projectImages" data-url="{:url('ajax/upload',array('from'=>'borrow'))}" data-mimetype="image/*" data-multiple="true" data-preview-id="p-projectImages"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                <span><button type="button" id="fachoose-projectImages" class="btn btn-primary fachoose" data-input-id="c-projectImages" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                <ul class="row list-inline plupload-preview" id="p-projectImages"></ul>
            </div>
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>


<script type="text/javascript">
    function chooserepay(){
        var choose = $('#c-isDay').val();
        if(choose==0){
            $('#repaystyle1').css('display','block');
            $('#repaystyle').css('display','none');
            $('#days').html('个月');
        }else if(choose==1){
            $('#repaystyle1').css('display','none');
            $('#repaystyle').css('display','block');
            $('#days').html('日');
        }
//        console.log(choose);
    }


    function choosetemp(){
        var choose = $('#borrowtemp').val();
        console.log(choose);

        $.post('{:url("borrowverify/choosetemp")}',
                {id: choose},
                function (data) {
                    console.log(data);
                    console.log(data.borrowerInfo);

                    if (data.code == 1) {

                        $('#c-name').val(data.title);
                        console.log('####');
                        console.log('borrower='+ data.borrowerInfo);
//                        $('#c-borrowerInfo').code(data.borrowerInfo);
                        $('#c-borrowerInfo').summernote('code',data.borrowerInfo);

                        $('#c-borrowerImages').val(data.borrowerImages);


                        if(data.borrowerImages!=''){
                            console.log(data.borrowerImages);
                            strs = data.borrowerImages.split(","); //字符分割
                            for (i=0;i<strs.length ;i++ )
                            {
//                                console.log(strs[i]);
                                var html = "<li class='col-xs-3'><a href='__IMGROOT__"+strs[i]+"' data-url='__IMGROOT__"+strs[i]+"' target='_blank' class='thumbnail'><img src='__IMGROOT__"+strs[i]+"' class='img-responsive'> </a><a href='javascript:;' class='btn btn-danger btn-xs btn-trash'><i class='fa fa-trash'></i></a></li>";
                                if(i==0){
                                    $('#p-borrowerImages').html(html);
                                }else{
                                    $('#p-borrowerImages').append(html);
                                }
                            }
                        }

//                        $('#c-itemInfo').code(data.itemInfo);
                        $('#c-itemInfo').summernote('code',data.itemInfo);
                        $('#c-itemImages').val(data.itemImages);
                        if(data.itemImages!=''){
                            strs = data.itemImages.split(","); //字符分割
                            for (i=0;i<strs.length ;i++ )
                            {
//                                console.log(strs[i]);
                                var html = "<li class='col-xs-3'><a href='__IMGROOT__"+strs[i]+"' data-url='__IMGROOT__"+strs[i]+"' target='_blank' class='thumbnail'><img src='__IMGROOT__"+strs[i]+"' class='img-responsive'> </a><a href='javascript:;' class='btn btn-danger btn-xs btn-trash'><i class='fa fa-trash'></i></a></li>";
                                if(i==0){
                                    $('#p-itemImages').html(html);
                                }else{
                                    $('#p-itemImages').append(html);
                                }
                            }
                        }
//                        $('#c-riskInfo').text(data.riskInfo);
                        $('#c-riskInfo').summernote('code',data.riskInfo);
                        $('#c-riskImages').val(data.riskImages);

                        if(data.riskImages!=''){
                            strs = data.riskImages.split(","); //字符分割
                            for (i=0;i<strs.length ;i++ )
                            {
//                                console.log(strs[i]);
                                var html = "<li class='col-xs-3'><a href='__IMGROOT__"+strs[i]+"' data-url='__IMGROOT__"+strs[i]+"' target='_blank' class='thumbnail'><img src='__IMGROOT__"+strs[i]+"' class='img-responsive'> </a><a href='javascript:;' class='btn btn-danger btn-xs btn-trash'><i class='fa fa-trash'></i></a></li>";
                                if(i==0){
                                    $('#p-riskImages').html(html);
                                }else{
                                    $('#p-riskImages').append(html);
                                }
                            }
                        }
//                        $('#c-projectInfo').text(data.projectInfo);
                        $('#c-projectInfo').summernote('code',data.projectInfo);
                        $('#c-projectImages').val(data.projectImages);
                        if(data.projectImages!=''){
                            strs = data.projectImages.split(","); //字符分割
                            for (i=0;i<strs.length ;i++ )
                            {
//                                console.log(strs[i]);
                                var html = "<li class='col-xs-3'><a href='__IMGROOT__"+strs[i]+"' data-url='__IMGROOT__"+strs[i]+"' target='_blank' class='thumbnail'><img src='__IMGROOT__"+strs[i]+"' class='img-responsive'> </a><a href='javascript:;' class='btn btn-danger btn-xs btn-trash'><i class='fa fa-trash'></i></a></li>";
                                if(i==0){
                                    $('#p-projectImages').html(html);
                                }else{
                                    $('#p-projectImages').append(html);
                                }
                            }
                        }
//                        $('#c-repaymentInfo').text(data.repaymentInfo);
                        $('#c-repaymentInfo').summernote('code',data.repaymentInfo);
                        $('#c-repaymentImages').val(data.repaymentImages);
                        if(data.repaymentImages!=''){
                            strs = data.repaymentImages.split(","); //字符分割
                            for (i=0;i<strs.length ;i++ )
                            {
//                                console.log(strs[i]);
                                var html = "<li class='col-xs-3'><a href='__IMGROOT__"+strs[i]+"' data-url='__IMGROOT__"+strs[i]+"' target='_blank' class='thumbnail'><img src='__IMGROOT__"+strs[i]+"' class='img-responsive'> </a><a href='javascript:;' class='btn btn-danger btn-xs btn-trash'><i class='fa fa-trash'></i></a></li>";
                                if(i==0){
                                    $('#p-repaymentImages').html(html);
                                }else{
                                    $('#p-repaymentImages').append(html);
                                }
                            }
                        }

                    } else {
                        console.log('@@@@');
                    }
                });
    }
</script>
